package com.ruoyi.common.sms.entinfo;

import com.ruoyi.common.sms.core.SmsProperties;
import com.ruoyi.common.sms.core.SmsTemplate;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * ClassName：EntinfoSmsAutoConfiguration
 * Package：com.ruoyi.common.sms.entinfo
 * Description：entinfo短信通道自动配置类
 *
 * @Author：fpy
 * @Create：2025/5/6 - 11:32
 * @Version：v1.0
 */
@RequiredArgsConstructor
@EnableConfigurationProperties({EntinfoSmsProperties.class})
public class EntinfoSmsAutoConfiguration {

    private final SmsProperties smsProperties;

    private final EntinfoSmsProperties entinfoSmsProperties;

    @Bean(name = "smsTemplate")
    @ConditionalOnMissingBean(SmsTemplate.class)
    @ConditionalOnProperty(name ="sms.type",havingValue = "entinfo")
    public SmsTemplate entinfoSmsTemplate() {
        return new EntinfoSmsTemplate(smsProperties,entinfoSmsProperties);
    }
}
